import Request from '@/utils/request'

/**
 * 订单相关API
 */
export default {
  /**
   * 创建订单
   * @param {object} orderData 订单数据
   */
  createOrder(orderData) {
    return Request.post('/api/customer/order/create', orderData)
  },

  /**
   * 获取订单列表
   * @param {object} params 查询参数
   */
  getOrderList(params = {}) {
    return Request.get('/api/customer/order/list', params)
  },

  /**
   * 获取订单详情
   * @param {number} orderId 订单ID
   */
  getOrderDetail(orderId) {
    return Request.get(`/api/customer/order/detail/${orderId}`)
  },

  /**
   * 取消订单
   * @param {number} orderId 订单ID
   * @param {string} reason 取消原因
   */
  cancelOrder(orderId, reason) {
    return Request.put(`/api/customer/order/cancel/${orderId}`, { reason })
  },

  /**
   * 确认收货
   * @param {number} orderId 订单ID
   */
  confirmOrder(orderId) {
    return Request.put(`/api/customer/order/confirm/${orderId}`)
  },

  /**
   * 申请退款
   * @param {number} orderId 订单ID
   * @param {string} reason 退款原因
   */
  applyRefund(orderId, reason) {
    return Request.post('/api/customer/order/refund', {
      orderId,
      reason
    })
  },

  /**
   * 微信支付
   * @param {number} orderId 订单ID
   */
  wxPay(orderId) {
    return Request.post('/api/customer/payment/wxpay', { orderId })
  },

  /**
   * 查询支付状态
   * @param {number} orderId 订单ID
   */
  getPaymentStatus(orderId) {
    return Request.get(`/api/customer/payment/status/${orderId}`)
  }
}